import { _decorator, Component, Animation, Node } from 'cc';
import { Config } from './Config';
import { AudioManager } from './AudioManager';
const { ccclass, property } = _decorator;

@ccclass('gameSkin')
export class gameSkin extends Component {
    @property(AudioManager)
    public audionManager: AudioManager = null!

    @property(Animation)
    public anim: Animation = null!;

    @property(Node)
    public mask: Node = null!;


    start() {
        this.mask.setScale(1, Config.heightScaling)

    }

    show() {
        this.node.active = true
        this.anim?.play('pop-up');
        this.audionManager.playSound()
    }

    hide() {
        this.anim?.play('pop-out');
        this.anim.on(Animation.EventType.STOP, this.onAnimationStop, this);
        this.audionManager.playSound()
    }

    onAnimationStop() {
        this.node.active = false;
        this.anim.off(Animation.EventType.STOP, this.onAnimationStop, this);
        //director.getScene().emit('destroy msg')
    }

}
